﻿using RayDen.Library.Core.Primitives;
using RayDen.Library.Entity.Scene;

namespace RayDen.Library.Data
{
    public class ConstSpectrumTexture : ITexture
    {

        public static ConstSpectrumTexture NullTexture = new ConstSpectrumTexture(new RgbSpectrumInfo(0f), 0, 0);

        private int width, height;
        private RgbSpectrumInfo data;
        public ConstSpectrumTexture(RgbSpectrumInfo data, int w, int h)
        {
            this.data = data;
            this.width = w;
            this.height = h;
            this.DUDV = new UV(1f / Width, 1f / Height);
        }

        #region ITexture Members

        public UV DUDV { get; set; }
        public int Width
        {
            get { return width; }
        }

        public int Height
        {
            get { return height; }
        }

        public RgbSpectrumInfo Sample(float u, float v)
        {
            return data;
        }

        public float SampleFloat(float u, float v)
        {
            return data.y();
        }

        public void Dispose()
        {
        }

        #endregion

    }
}